# -*- coding: UTF-8 -*-
"""
Create by Louis on 2020/7/26-21:19
"""
# __author__ = "Louis"
from . import bp
from flask import request
import json


@bp.route('/get_request_info', methods=['post', 'get'])
def get_request_info():
    resp = dict()
    print(dir(request))
    print(request.__dict__)
    resp['headers'] = dict(request.headers)
    resp['params_data'] = dict(request.data)
    resp['params_form'] = dict(request.form)
    resp['params_query'] = dict(request.args)
    resp['status'] = 200
    resp['message'] = "success"

    return resp


@bp.route('/get_request_info_json', methods=['GET', 'POST'])
def get_user_json():
    if request.method == 'POST':
        a = request.get_data()
        dict1 = json.loads(a)
        print(dict1)
        return json.dumps(dict1["data"])
    else:
        return '<h1>只接受post请求！</h1>'


@bp.route('/getname/<name>')
def user(name):
    return '<h1>hello, %s</h1>' % name
